<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!DOCTYPE html>
<html lang="en">
	<head>
	<%@ include file="/view/common/head.jsp" %>
	</head>
	<body>
    <!-- Fixed navbar -->
   	<%@ include file="/view/common/nav.jsp" %>

    <div class="container">
    	<div class="row">
    		<div class="col-sm-12 col-md-8">
    			<div class="panel panel-default">
    				<div class="panel-heading">社团活动</div>
    			</div>
    			<c:forEach items="${articlePage.list}" var="article">
	    			<div class="cell topic">
						<div class="item_title">
						     <div class="caption">
						     <c:choose>
							 <c:when test="${article.flag==1}">
							  <h5><a href="article/viewzm/${article.id}" class="startbbs topic">${article.title}</a></h5>
                             </c:when>
							 <c:otherwise>
							  <h5><a href="article/view/${article.id}" class="startbbs topic">${article.title}</a></h5>
							 </c:otherwise>
							 </c:choose>                   
                             <c:choose>
							 <c:when test="${article.flag==1}">
							 <p>${article.content}</p>
                             </c:when>
							 <c:otherwise>
							 </c:otherwise>
							 </c:choose>
                             <p>${article.createUserName} | ${fn:substring(article.createTime, 0, 16)}</p>
							 <c:choose>
							 <c:when test="${article.flag==1}">
							 <%if(session.getAttribute("uname") != null){
								 %>
								 <p><a role="button" class="btn btn-primary" onclick="addToSt(<%=session.getAttribute("uid") %>,${article.belong})">加入社团</a></p>
								 <%
							 } %>
                             </c:when>
							 <c:otherwise>
							 </c:otherwise>
							 </c:choose>
                             </div>
						</div>
					</div>
				</c:forEach>
    		</div>
    		<div class="col-sm-12 col-md-4">
				<%@ include file="/view/common/about.jsp"%>
    		</div>
    	</div>
    </div> 
    <%@ include file="/view/common/foot.jsp" %>
    <script type="text/javascript">
    function addToSt(id,uid){
        var jsonData = {
        	'id':id,
            'uid':uid
        };
        $.ajax({
            url: "user/upUserToSt",
            data: jsonData,
            type: "post",
            success: function (backdata) {
                if (backdata == 1) {
                	bootbox.alert("加入成功！");
                } else if (backdata == 0) {
                	bootbox.alert("更新失败");
                } else {
                	bootbox.alert("出现异常");
                }
            }, error: function (error) {
                console.log(error);
            }
        });
    }
    </script>
</body></html>
